home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume14 / jove4.9 / part09 < prev    next >
Encoding:
Internet Message Format  |  1988-04-25  |  38.7 KB

  1. Subject:  v14i065:  Jove, an emacs variant, version 4.9, Part09/21
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: Jonathan Payne <jpayne@cs.rochester.edu>
  7. Posting-number: Volume 14, Issue 65
  8. Archive-name: jove4.9/part09
  9.  
  10. #! /bin/sh
  11. # This is a shell archive.  Remove anything before this line, then unpack
  12. # it by saving it into a file and typing "sh file".  To overwrite existing
  13. # files, type "sh file -c".  You can also feed this as standard input via
  14. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  15. # will see the following message at the end:
  16. #        "End of archive 9 (of 21)."
  17. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  18. if test -f './funcdefs.c' -a "${1}" != "-c" ; then 
  19.   echo shar: Will not clobber existing file \"'./funcdefs.c'\"
  20. else
  21. echo shar: Extracting \"'./funcdefs.c'\" \(18218 characters\)
  22. sed "s/^X//" >'./funcdefs.c' <<'END_OF_FILE'
  23. X/***************************************************************************
  24. X * This program is Copyright (C) 1986, 1987, 1988 by Jonathan Payne.  JOVE *
  25. X * is provided to you without charge, and with no warranty.  You may give  *
  26. X * away copies of JOVE, including sources, provided that this notice is    *
  27. X * included in all the files.                                              *
  28. X ***************************************************************************/
  29. X
  30. X#include "jove.h"
  31. X#include "ctype.h"
  32. X
  33. X#if !defined(TXT_TO_C) 
  34. extern void
  35. X    EscPrefix(),
  36. X    CtlxPrefix(),
  37. X    MiscPrefix(),
  38. X    UnbindC(),
  39. X    ShowVersion(),
  40. X    WVisSpace(),
  41. X#ifdef ANSICODES
  42. X    AnsiCodes(),
  43. X#endif
  44. X    AppReg(),
  45. X    Apropos(),
  46. X    BackChar(),
  47. X    BList(),
  48. X    FList(),
  49. X    BUpList(),
  50. X    FDownList(),
  51. X    BSexpr(),
  52. X    BackWord(),
  53. X    Bof(),
  54. X    Bol(),
  55. X    Bos(),
  56. X    Bow(),
  57. X    BindAKey(),
  58. X    BindMac(),
  59. X    BufPos(),
  60. X#ifdef MSDOS
  61. X    Buf1Select(),
  62. X    Buf2Select(),
  63. X    Buf3Select(),
  64. X    Buf4Select(),
  65. X    Buf5Select(),
  66. X    Buf6Select(),
  67. X    Buf7Select(),
  68. X    Buf8Select(),
  69. X    Buf9Select(),
  70. X    Buf10Select(),
  71. X#endif /* MSDOS */
  72. X    CasRegLower(),
  73. X    CasRegUpper(),
  74. X    CapChar(),
  75. X    CapWord(),
  76. X    LowWord(),
  77. X    UppWord(),
  78. X#ifdef CHDIR
  79. X    Chdir(),
  80. X    prCWD(),
  81. X    prDIRS(),
  82. X    Pushd(),
  83. X    Popd(),
  84. X#endif
  85. X    prCTIME(),
  86. X    ChrToOct(),
  87. X    ClAndRedraw(),
  88. X#ifndef MAC
  89. X    MakeErrors(),
  90. X#endif
  91. X    CopyRegion(),
  92. X    BufSelect(),
  93. X    DelBlnkLines(),
  94. X    DelNChar(),
  95. X    DelNWord(),
  96. X    OneWindow(),
  97. X    DelPChar(),
  98. X    DelPWord(),
  99. X    DelReg(),
  100. X    KillSome(),
  101. X    DelWtSpace(),
  102. X    DelCurWindow(),
  103. X    KeyDesc(),
  104. X    Digit(),
  105. X    Digit0(),
  106. X    Digit1(),
  107. X    Digit2(),
  108. X    Digit3(),
  109. X    Digit4(),
  110. X    Digit5(),
  111. X    Digit6(),
  112. X    Digit7(),
  113. X    Digit8(),
  114. X    Digit9(),
  115. X    DescBindings(),
  116. X    DescCom(),
  117. X    Eof(),
  118. X    Eol(),
  119. X    Eos(),
  120. X    Eow(),
  121. X    ForPara(),
  122. X    BackPara(),
  123. X    BufErase(),
  124. X    PtToMark(),
  125. X    Extend(),
  126. X    ExecMacro(),
  127. X    RunMacro(),
  128. X    Leave(),
  129. X    FindFile(),
  130. X    WindFind(),
  131. X    FindTag(),
  132. X    FDotTag(),
  133. X    ToIndent(),
  134. X    ForChar(),
  135. X    FSexpr(),
  136. X    ForWord(),
  137. X    TimesFour(),
  138. X    GoLine(),
  139. X    GrowWindow(),
  140. X    IncFSearch(),
  141. X    IncRSearch(),
  142. X    InsFile(),
  143. X    Justify(),
  144. X    RegJustify(),
  145. X    SetLMargin(),
  146. X    SetRMargin(),
  147. X    BufKill(),
  148. X    KillBos(),
  149. X    KillEos(),
  150. X    KillEOL(),
  151. X    KillExpr(),
  152. X    BufList(),
  153. X    NotModified(),
  154. X    NameMac(),
  155. X    DelMacro(),
  156. X    Newline(),
  157. X    OpenLine(),
  158. X    LineAI(),
  159. X#ifndef MAC
  160. X    ShowErr(),
  161. X    NextError(),
  162. X#endif /* MAC */
  163. X#ifdef MSDOS
  164. X    PageScrollUp(),
  165. X    PageScrollDown(),
  166. X#endif /* MSDOS */
  167. X#ifndef MAC
  168. X    PrevError(),
  169. X#endif /* MAC */
  170. X    NextLine(),
  171. X    NextPage(),
  172. X    NextWindow(),
  173. X    Recur(),
  174. X    PopMark(),
  175. X    PageNWind(),
  176. X    Tab(),
  177. X    DoParen(),
  178. X#ifndef MAC
  179. X    ParseAll(),
  180. X#endif
  181. X#ifdef SPELL
  182. X    SpelWords(),
  183. X#endif
  184. X#ifdef JOB_CONTROL
  185. X    PauseJove(),
  186. X#endif
  187. X    PrevLine(),
  188. X    PrevPage(),
  189. X    PrevWindow(),
  190. X#ifndef MAC
  191. X    Push(),
  192. X#endif
  193. X    RegReplace(),
  194. X    QRepSearch(),
  195. X    QuotChar(),
  196. X    ReadFile(),
  197. X    DefKBDMac(),
  198. X    RedrawDisplay(),
  199. X    ReNamBuf(),
  200. X    RepSearch(),
  201. X    DownScroll(),
  202. X    UpScroll(),
  203. X    ForSearch(),
  204. X    FSrchND(),
  205. X    RevSearch(),
  206. X    RSrchND(),
  207. X    SelfInsert(),
  208. X    SetVar(),
  209. X     SetMark(),
  210. X#ifndef MAC
  211. X    ShellCom(),
  212. X    ShNoBuf(),
  213. X    Shtypeout(),
  214. X    ShToBuf(),
  215. X#endif
  216. X    ShrWindow(),
  217. X    Source(),
  218. X#ifdef SPELL
  219. X    SpelBuffer(),
  220. X#endif
  221. X    SplitWind(),
  222. X    GotoWind(),
  223. X    Remember(),
  224. X    Forget(),
  225. X    StrLength(),
  226. X    TransChar(),
  227. X    TransLines(),
  228. X    SaveFile(),
  229. X    WtModBuf(),
  230. X    WriteFile(),
  231. X    WriteMacs(),
  232. X    WrtReg(),
  233. X    Yank(),
  234. X    YankPop(),    PrVar(),
  235. X#ifndef MAC
  236. X    FilterRegion(),
  237. X#endif
  238. X    WNumLines(),
  239. X#ifdef IPROCS
  240. X    ShellProc(),
  241. X    ProcInt(),
  242. X    ProcQuit(),
  243. X    ProcKill(),
  244. X#  ifndef PIPEPROCS
  245. X    ProcEof(),
  246. X    ProcStop(),
  247. X    ProcCont(),
  248. X    ProcDStop(),
  249. X#  endif
  250. X    ProcSendData(),
  251. X    ProcNewline(),
  252. X    ProcList(),
  253. X    ProcBind(),
  254. X    Iprocess(),
  255. X#endif
  256. X
  257. X#ifdef LISP
  258. X    GSexpr(),    /* Grind S Expression. */
  259. X    AddSpecial(),    /* add lisp special form */
  260. X#endif
  261. X    CAutoExec(),
  262. X    MAutoExec(),
  263. X
  264. X    DefMAbbrev(),
  265. X    DefGAbbrev(),
  266. X    SaveAbbrevs(),
  267. X    RestAbbrevs(),
  268. X    EditAbbrevs(),
  269. X    BindMtoW(),
  270. X
  271. X#ifdef CMT_FMT
  272. X    Comment(),
  273. X#endif
  274. X
  275. X    ScrollLeft(),
  276. X    ScrollRight(),
  277. X    MacInter();        /* This is the last one. */
  278. X
  279. X
  280. X#ifdef MAC
  281. X#    define WIRED_CMD(c) c,'\0','\0'    /* for About Jove... */
  282. X#else
  283. X#    define WIRED_CMD(c)    c
  284. X#endif /* MAC */
  285. X
  286. X#else /* TXT_TO_C */
  287. X
  288. X#ifdef MAC
  289. X#    define WIRED_CMD(c) 0,'\0','\0'
  290. X#else
  291. X#    define WIRED_CMD(c)    0
  292. X#endif
  293. X#endif /* TXT_TO_C */
  294. X
  295. struct cmd    commands[] = {
  296. X#ifdef LISP
  297. X    FUNCTION, "add-lisp-special", WIRED_CMD(AddSpecial),
  298. X#endif
  299. X#ifdef ANSICODES
  300. X    FUNCTION, "ansi-codes", WIRED_CMD(AnsiCodes),
  301. X#endif
  302. X    FUNCTION, "append-region", WIRED_CMD(AppReg),
  303. X    FUNCTION, "apropos", WIRED_CMD(Apropos),
  304. X    FUNCTION, "auto-execute-command", WIRED_CMD(CAutoExec),
  305. X    FUNCTION, "auto-execute-macro", WIRED_CMD(MAutoExec),
  306. X    DefMinor(Fill), "auto-fill-mode", WIRED_CMD(0),
  307. X    DefMinor(Indent), "auto-indent-mode", WIRED_CMD(0),
  308. X    FUNCTION, "backward-character", WIRED_CMD(BackChar),
  309. X    FUNCTION, "backward-list", WIRED_CMD(BList),
  310. X    FUNCTION, "backward-paragraph", WIRED_CMD(BackPara),
  311. X    FUNCTION, "backward-s-expression", WIRED_CMD(BSexpr),
  312. X    FUNCTION, "backward-sentence", WIRED_CMD(Bos),
  313. X    FUNCTION, "backward-up-list", WIRED_CMD(BUpList),
  314. X    FUNCTION, "backward-word", WIRED_CMD(BackWord),
  315. X    FUNCTION, "begin-kbd-macro", WIRED_CMD(Remember),
  316. X    FUNCTION, "beginning-of-file", WIRED_CMD(Bof),
  317. X    FUNCTION, "beginning-of-line", WIRED_CMD(Bol),
  318. X    FUNCTION, "beginning-of-window", WIRED_CMD(Bow),
  319. X    FUNCTION, "bind-to-key", WIRED_CMD(BindAKey),
  320. X    FUNCTION, "bind-macro-to-key", WIRED_CMD(BindMac),
  321. X#ifdef ABBREV
  322. X    FUNCTION, "bind-macro-to-word-abbrev", WIRED_CMD(BindMtoW),
  323. X#endif
  324. X    FUNCTION, "buffer-position", WIRED_CMD(BufPos),
  325. X    DefMajor(CMODE), "c-mode", WIRED_CMD(0),
  326. X    FUNCTION, "case-character-capitalize", WIRED_CMD(CapChar),
  327. X    FUNCTION, "case-region-lower", WIRED_CMD(CasRegLower),
  328. X    FUNCTION, "case-region-upper", WIRED_CMD(CasRegUpper),
  329. X    FUNCTION, "case-word-capitalize", WIRED_CMD(CapWord),
  330. X    FUNCTION, "case-word-lower", WIRED_CMD(LowWord),
  331. X    FUNCTION, "case-word-upper", WIRED_CMD(UppWord),
  332. X    FUNCTION, "character-to-octal-insert", WIRED_CMD(ChrToOct),
  333. X#ifdef CHDIR
  334. X    FUNCTION, "cd", WIRED_CMD(Chdir),
  335. X#endif
  336. X    FUNCTION, "clear-and-redraw", WIRED_CMD(ClAndRedraw),
  337. X#ifndef MAC
  338. X    FUNCTION, "compile-it", WIRED_CMD(MakeErrors),
  339. X#endif
  340. X#ifdef IPROCS
  341. X#  ifndef PIPEPROCS
  342. X#    ifdef TIOCSLTC
  343. X    FUNCTION, "continue-process", WIRED_CMD(ProcCont),
  344. X#    endif
  345. X#  endif
  346. X#endif
  347. X    FUNCTION, "copy-region", WIRED_CMD(CopyRegion),
  348. X#ifndef MAC
  349. X    FUNCTION, "current-error", WIRED_CMD(ShowErr),
  350. X#endif
  351. X    FUNCTION, "date", WIRED_CMD(prCTIME),
  352. X#ifdef ABBREV
  353. X    FUNCTION, "define-global-word-abbrev", WIRED_CMD(DefGAbbrev),
  354. X    FUNCTION, "define-mode-word-abbrev", WIRED_CMD(DefMAbbrev),
  355. X#endif
  356. X    FUNCTION, "define-macro", WIRED_CMD(DefKBDMac),
  357. X    FUNCTION, "delete-blank-lines", WIRED_CMD(DelBlnkLines),
  358. X    FUNCTION, "delete-buffer", WIRED_CMD(BufKill),
  359. X    FUNCTION, "delete-macro", WIRED_CMD(DelMacro),
  360. X    FUNCTION, "delete-next-character", WIRED_CMD(DelNChar),
  361. X    FUNCTION, "delete-other-windows", WIRED_CMD(OneWindow),
  362. X    FUNCTION, "delete-previous-character", WIRED_CMD(DelPChar),
  363. X    FUNCTION, "delete-white-space", WIRED_CMD(DelWtSpace),
  364. X    FUNCTION, "delete-current-window", WIRED_CMD(DelCurWindow),
  365. X    FUNCTION, "describe-bindings", WIRED_CMD(DescBindings),
  366. X    FUNCTION, "describe-command", WIRED_CMD(DescCom),
  367. X    FUNCTION, "describe-key", WIRED_CMD(KeyDesc),
  368. X    FUNCTION, "describe-variable", WIRED_CMD(DescCom),
  369. X    FUNCTION, "digit", WIRED_CMD(Digit),
  370. X    FUNCTION, "digit-1", WIRED_CMD(Digit1),
  371. X    FUNCTION, "digit-2", WIRED_CMD(Digit2),
  372. X    FUNCTION, "digit-3", WIRED_CMD(Digit3),
  373. X    FUNCTION, "digit-4", WIRED_CMD(Digit4),
  374. X    FUNCTION, "digit-5", WIRED_CMD(Digit5),
  375. X    FUNCTION, "digit-6", WIRED_CMD(Digit6),
  376. X    FUNCTION, "digit-7", WIRED_CMD(Digit7),
  377. X    FUNCTION, "digit-8", WIRED_CMD(Digit8),
  378. X    FUNCTION, "digit-9", WIRED_CMD(Digit9),
  379. X    FUNCTION, "digit-0", WIRED_CMD(Digit0),
  380. X#ifdef CHDIR
  381. X    FUNCTION, "dirs", WIRED_CMD(prDIRS),
  382. X#endif
  383. X    FUNCTION, "down-list", WIRED_CMD(FDownList),
  384. X#ifdef IPROCS
  385. X#  ifndef PIPEPROCS
  386. X#    ifdef TIOCSLTC
  387. X    FUNCTION, "dstop-process", WIRED_CMD(ProcDStop),
  388. X#    endif
  389. X#  endif
  390. X#endif
  391. X#ifdef ABBREV
  392. X    FUNCTION, "edit-word-abbrevs", WIRED_CMD(EditAbbrevs),
  393. X#endif
  394. X    FUNCTION, "end-kbd-macro", WIRED_CMD(Forget),
  395. X    FUNCTION, "end-of-file", WIRED_CMD(Eof),
  396. X    FUNCTION, "end-of-line", WIRED_CMD(Eol),
  397. X    FUNCTION, "end-of-window", WIRED_CMD(Eow),
  398. X#ifdef IPROCS
  399. X#  ifndef PIPEPROCS
  400. X    FUNCTION, "eof-process", WIRED_CMD(ProcEof),
  401. X#  endif
  402. X#endif
  403. X    FUNCTION, "erase-buffer", WIRED_CMD(BufErase),
  404. X    FUNCTION, "exchange-point-and-mark", WIRED_CMD(PtToMark),
  405. X    FUNCTION, "execute-named-command", WIRED_CMD(Extend),
  406. X    FUNCTION, "execute-kbd-macro", WIRED_CMD(ExecMacro),
  407. X    FUNCTION, "execute-macro", WIRED_CMD(RunMacro),
  408. X    FUNCTION, "exit-jove", WIRED_CMD(Leave),
  409. X#ifdef CMT_FMT
  410. X     FUNCTION, "fill-comment", WIRED_CMD(Comment),
  411. X#endif /* CMT_FMT */
  412. X    FUNCTION, "fill-paragraph", WIRED_CMD(Justify),
  413. X    FUNCTION, "fill-region", WIRED_CMD(RegJustify),
  414. X#ifndef MAC
  415. X    FUNCTION, "filter-region", WIRED_CMD(FilterRegion),
  416. X#endif
  417. X    FUNCTION, "find-file", WIRED_CMD(FindFile),
  418. X    FUNCTION, "find-tag", WIRED_CMD(FindTag),
  419. X    FUNCTION, "find-tag-at-point", WIRED_CMD(FDotTag),
  420. X    FUNCTION, "first-non-blank", WIRED_CMD(ToIndent),
  421. X    FUNCTION, "forward-character", WIRED_CMD(ForChar),
  422. X    FUNCTION, "forward-list", WIRED_CMD(FList),
  423. X    FUNCTION, "forward-paragraph", WIRED_CMD(ForPara),
  424. X    FUNCTION, "forward-s-expression", WIRED_CMD(FSexpr),
  425. X    FUNCTION, "forward-sentence", WIRED_CMD(Eos),
  426. X    FUNCTION, "forward-word", WIRED_CMD(ForWord),
  427. X    DefMajor(FUNDAMENTAL), "fundamental-mode", WIRED_CMD(0),
  428. X    FUNCTION, "gather-numeric-argument", WIRED_CMD(TimesFour),
  429. X#ifdef LISP
  430. X    FUNCTION, "grind-s-expr", WIRED_CMD(GSexpr),
  431. X#endif
  432. X    FUNCTION, "goto-line", WIRED_CMD(GoLine),
  433. X    FUNCTION, "goto-window-with-buffer", WIRED_CMD(GotoWind),
  434. X    FUNCTION, "grow-window", WIRED_CMD(GrowWindow),
  435. X    FUNCTION, "handle-tab", WIRED_CMD(Tab),
  436. X    FUNCTION, "i-search-forward", WIRED_CMD(IncFSearch),
  437. X    FUNCTION, "i-search-reverse", WIRED_CMD(IncRSearch),
  438. X    FUNCTION, "insert-file", WIRED_CMD(InsFile),
  439. X#ifdef IPROCS
  440. X    FUNCTION, "interrupt-process", WIRED_CMD(ProcInt),
  441. X    FUNCTION, "i-shell-command", WIRED_CMD(Iprocess),
  442. X#endif
  443. X    FUNCTION, "kill-next-word", WIRED_CMD(DelNWord),
  444. X    FUNCTION, "kill-previous-word", WIRED_CMD(DelPWord),
  445. X#ifdef IPROCS
  446. X    FUNCTION, "kill-process", WIRED_CMD(ProcKill),
  447. X#endif
  448. X    FUNCTION, "kill-region", WIRED_CMD(DelReg),
  449. X    FUNCTION, "kill-s-expression", WIRED_CMD(KillExpr),
  450. X    FUNCTION, "kill-some-buffers", WIRED_CMD(KillSome),
  451. X    FUNCTION, "kill-to-beginning-of-sentence", WIRED_CMD(KillBos),
  452. X    FUNCTION, "kill-to-end-of-line", WIRED_CMD(KillEOL),
  453. X    FUNCTION, "kill-to-end-of-sentence", WIRED_CMD(KillEos),
  454. X    FUNCTION, "left-margin-here", WIRED_CMD(SetLMargin),
  455. X#ifdef LISP
  456. X    DefMajor(LISPMODE), "lisp-mode", WIRED_CMD(0),
  457. X#endif
  458. X    FUNCTION, "list-buffers", WIRED_CMD(BufList),
  459. X#ifdef IPROCS
  460. X    FUNCTION, "list-processes", WIRED_CMD(ProcList),
  461. X#endif
  462. X    FUNCTION, "make-buffer-unmodified", WIRED_CMD(NotModified),
  463. X    FUNCTION, "make-macro-interactive", WIRED_CMD(MacInter),
  464. X    FUNCTION, "name-kbd-macro", WIRED_CMD(NameMac),
  465. X    FUNCTION, "newline", WIRED_CMD(Newline),
  466. X    FUNCTION, "newline-and-backup", WIRED_CMD(OpenLine),
  467. X    FUNCTION, "newline-and-indent", WIRED_CMD(LineAI),
  468. X#ifndef MAC
  469. X    FUNCTION, "next-error", WIRED_CMD(NextError),
  470. X#endif
  471. X    FUNCTION, "next-line", WIRED_CMD(NextLine),
  472. X    FUNCTION, "next-page", WIRED_CMD(NextPage),
  473. X    FUNCTION, "next-window", WIRED_CMD(NextWindow),
  474. X    FUNCTION, "number-lines-in-window", WIRED_CMD(WNumLines),
  475. X    DefMinor(OverWrite), "over-write-mode", WIRED_CMD(0),
  476. X    FUNCTION, "page-next-window", WIRED_CMD(PageNWind),
  477. X    FUNCTION, "paren-flash", WIRED_CMD(DoParen),
  478. X#ifndef MAC
  479. X    FUNCTION, "parse-errors", WIRED_CMD(ErrParse),
  480. X#endif
  481. X#ifdef SPELL
  482. X    FUNCTION, "parse-spelling-errors-in-buffer", WIRED_CMD(SpelWords),
  483. X#endif
  484. X#ifdef JOB_CONTROL
  485. X    FUNCTION, "pause-jove", WIRED_CMD(PauseJove),
  486. X#else
  487. X#    ifndef MAC
  488. X    FUNCTION, "pause-jove", WIRED_CMD(Push),
  489. X#    endif
  490. X#endif
  491. X    FUNCTION, "pop-mark", WIRED_CMD(PopMark),
  492. X#ifdef CHDIR
  493. X    FUNCTION, "popd", WIRED_CMD(Popd),
  494. X#endif
  495. X    FUNCTION, "prefix-1", WIRED_CMD(EscPrefix),
  496. X    FUNCTION, "prefix-2", WIRED_CMD(CtlxPrefix),
  497. X    FUNCTION, "prefix-3", WIRED_CMD(MiscPrefix),
  498. X#ifndef MAC
  499. X    FUNCTION, "previous-error", WIRED_CMD(PrevError),
  500. X#endif
  501. X    FUNCTION, "previous-line", WIRED_CMD(PrevLine),
  502. X    FUNCTION, "previous-page", WIRED_CMD(PrevPage),
  503. X    FUNCTION, "previous-window", WIRED_CMD(PrevWindow),
  504. X    FUNCTION, "print", WIRED_CMD(PrVar),
  505. X#ifdef IPROCS
  506. X    FUNCTION, "process-bind-to-key", WIRED_CMD(ProcBind),
  507. X    FUNCTION, "process-newline", WIRED_CMD(ProcNewline),
  508. X    FUNCTION, "process-send-data-no-return", WIRED_CMD(ProcSendData),
  509. X#endif
  510. X#ifndef MAC
  511. X    FUNCTION, "push-shell", WIRED_CMD(Push),
  512. X#endif
  513. X#ifdef CHDIR
  514. X    FUNCTION, "pushd", WIRED_CMD(Pushd),
  515. X    FUNCTION, "pwd", WIRED_CMD(prCWD),
  516. X#endif
  517. X    FUNCTION, "query-replace-string", WIRED_CMD(QRepSearch),
  518. X#ifdef IPROCS
  519. X    FUNCTION, "quit-process", WIRED_CMD(ProcQuit),
  520. X#endif
  521. X    FUNCTION, "quoted-insert", WIRED_CMD(QuotChar),
  522. X#ifdef ABBREV
  523. X    FUNCTION, "read-word-abbrev-file", WIRED_CMD(RestAbbrevs),
  524. X#endif
  525. X    FUNCTION, "redraw-display", WIRED_CMD(RedrawDisplay),
  526. X    FUNCTION, "recursive-edit", WIRED_CMD(Recur),
  527. X    FUNCTION, "rename-buffer", WIRED_CMD(ReNamBuf),
  528. X    FUNCTION, "replace-in-region", WIRED_CMD(RegReplace),
  529. X    FUNCTION, "replace-string", WIRED_CMD(RepSearch),
  530. X    FUNCTION, "right-margin-here", WIRED_CMD(SetRMargin),
  531. X    FUNCTION, "save-file", WIRED_CMD(SaveFile),
  532. X    FUNCTION, "scroll-down", WIRED_CMD(DownScroll),
  533. X    FUNCTION, "scroll-left", WIRED_CMD(ScrollLeft),
  534. X#ifdef MSDOS
  535. X    FUNCTION, "scroll-next-page", WIRED_CMD(PageScrollUp),
  536. X    FUNCTION, "scroll-previous-page", WIRED_CMD(PageScrollDown),
  537. X#endif /* MSDOS */
  538. X    FUNCTION, "scroll-right", WIRED_CMD(ScrollRight),
  539. X    FUNCTION, "scroll-up", WIRED_CMD(UpScroll),
  540. X    FUNCTION, "search-forward", WIRED_CMD(ForSearch),
  541. X    FUNCTION, "search-forward-nd", WIRED_CMD(FSrchND),
  542. X    FUNCTION, "search-reverse", WIRED_CMD(RevSearch),
  543. X    FUNCTION, "search-reverse-nd", WIRED_CMD(RSrchND),
  544. X    FUNCTION, "select-buffer", WIRED_CMD(BufSelect),
  545. X#ifdef MSDOS
  546. X    FUNCTION, "select-buffer-1", WIRED_CMD(Buf1Select),
  547. X    FUNCTION, "select-buffer-2", WIRED_CMD(Buf2Select),
  548. X    FUNCTION, "select-buffer-3", WIRED_CMD(Buf3Select),
  549. X    FUNCTION, "select-buffer-4", WIRED_CMD(Buf4Select),
  550. X    FUNCTION, "select-buffer-5", WIRED_CMD(Buf5Select),
  551. X    FUNCTION, "select-buffer-6", WIRED_CMD(Buf6Select),
  552. X    FUNCTION, "select-buffer-7", WIRED_CMD(Buf7Select),
  553. X    FUNCTION, "select-buffer-8", WIRED_CMD(Buf8Select),
  554. X    FUNCTION, "select-buffer-9", WIRED_CMD(Buf9Select),
  555. X    FUNCTION, "select-buffer-10", WIRED_CMD(Buf10Select),
  556. X#endif /* MSDOS */
  557. X    FUNCTION, "self-insert", WIRED_CMD(SelfInsert),
  558. X    FUNCTION, "set", WIRED_CMD(SetVar),
  559. X    FUNCTION, "set-mark", WIRED_CMD(SetMark),
  560. X#ifdef IPROCS    /* for GNU compatibility */
  561. X    FUNCTION, "shell", WIRED_CMD(ShellProc),
  562. X#endif
  563. X#ifndef MAC
  564. X    FUNCTION, "shell-command", WIRED_CMD(ShellCom),
  565. X    FUNCTION, "shell-command-no-buffer", WIRED_CMD(ShNoBuf),
  566. X    FUNCTION, "shell-command-to-buffer", WIRED_CMD(ShToBuf),
  567. X    FUNCTION, "shell-command-with-typeout", WIRED_CMD(Shtypeout),
  568. X#endif
  569. X    DefMinor(ShowMatch), "show-match-mode", WIRED_CMD(0),
  570. X    FUNCTION, "shrink-window", WIRED_CMD(ShrWindow),
  571. X    FUNCTION, "source", WIRED_CMD(Source),
  572. X#ifdef SPELL
  573. X    FUNCTION, "spell-buffer", WIRED_CMD(SpelBuffer),
  574. X#endif
  575. X    FUNCTION, "split-current-window", WIRED_CMD(SplitWind),
  576. X    FUNCTION, "start-remembering", WIRED_CMD(Remember),
  577. X#ifdef IPROCS
  578. X#  ifndef PIPEPROCS
  579. X    FUNCTION, "stop-process", WIRED_CMD(ProcStop),
  580. X#  endif
  581. X#endif
  582. X    FUNCTION, "stop-remembering", WIRED_CMD(Forget),
  583. X    FUNCTION, "string-length", WIRED_CMD(StrLength),
  584. X#ifdef JOB_CONTROL
  585. X    FUNCTION, "suspend-jove", WIRED_CMD(PauseJove),
  586. X#endif
  587. X    DefMajor(TEXT), "text-mode", WIRED_CMD(0),
  588. X    FUNCTION, "transpose-characters", WIRED_CMD(TransChar),
  589. X    FUNCTION, "transpose-lines", WIRED_CMD(TransLines),
  590. X    FUNCTION, "unbind-key", WIRED_CMD(UnbindC),
  591. X    FUNCTION, "version", WIRED_CMD(ShowVersion),
  592. X    FUNCTION, "visible-spaces-in-window", WIRED_CMD(WVisSpace),
  593. X    FUNCTION, "visit-file", WIRED_CMD(ReadFile),
  594. X    FUNCTION, "window-find", WIRED_CMD(WindFind),
  595. X#ifdef ABBREV
  596. X    DefMinor(Abbrev), "word-abbrev-mode", WIRED_CMD(0),
  597. X    FUNCTION, "write-word-abbrev-file", WIRED_CMD(SaveAbbrevs),
  598. X#endif
  599. X    FUNCTION, "write-file", WIRED_CMD(WriteFile),
  600. X    FUNCTION, "write-macros-to-file", WIRED_CMD(WriteMacs),
  601. X    FUNCTION, "write-modified-files", WIRED_CMD(WtModBuf),
  602. X    FUNCTION, "write-region", WIRED_CMD(WrtReg),
  603. X    FUNCTION, "yank", WIRED_CMD(Yank),
  604. X    FUNCTION, "yank-pop", WIRED_CMD(YankPop),
  605. X    FUNCTION, 0, 0
  606. X};
  607. X
  608. X#ifndef TXT_TO_C
  609. data_obj *
  610. findcom(prompt)
  611. char    *prompt;
  612. X{
  613. X    /* This is for faster startup.  This just reads until a space or a
  614. X       tab or a newline character is reached, and then does a
  615. X       semi-hashed lookup on that string.  This should be much faster
  616. X       than initializing the minibuffer for each line. */
  617. X    if (InJoverc) {
  618. X        char    cmdbuf[128];
  619. X        register struct cmd    *cmd;
  620. X        register char    *cp = cmdbuf;
  621. X#if !(defined(IBMPC) || defined(MAC))
  622. X        register int    c;
  623. X#else
  624. X        int c;
  625. X#endif        
  626. X        struct cmd    *which;
  627. X        int    cmdlen,
  628. X            found = 0;
  629. X        static struct cmd    *cmdhash[26];
  630. X        static int    beenhere = NO;
  631. X
  632. X/* special case for prefix commands--only upper case ones */
  633. X#define hash(c)    (c - 'a')
  634. X
  635. X        /* initialize the hash table */
  636. X        if (beenhere == NO) {
  637. X            int    lastc = 0;
  638. X
  639. X            for (cmd = commands; cmd->Name != 0; cmd++)
  640. X                if (lastc != cmd->Name[0]) {
  641. X                    lastc = cmd->Name[0];
  642. X                    cmdhash[hash(lastc)] = cmd;
  643. X                }
  644. X            beenhere = YES;
  645. X        }
  646. X#ifdef MAC
  647. X        menus_off();    /* Block menu choices during input */
  648. X#endif
  649. X        /* gather the cmd name */
  650. X        while (((c = getch()) != EOF) && !index(" \t\r\n", c)) {
  651. X#if (defined(IBMPC) || defined(MAC))
  652. X            lower(&c);
  653. X#else            
  654. X            if (isupper(c))
  655. X                c = tolower(c);
  656. X#endif
  657. X            *cp++ = c;
  658. X        }
  659. X        if (c == EOF)
  660. X            return 0;
  661. X        *cp = '\0';
  662. X        cmdlen = cp - cmdbuf;
  663. X        if (cmdlen == 0)
  664. X            return 0;
  665. X
  666. X        /* look it up (in the reduced search space) */
  667. X        if (islower(cmdbuf[0]))
  668. X            for (cmd = cmdhash[hash(cmdbuf[0])]; cmd != 0 && cmd->Name[0] == cmdbuf[0]; cmd++) {
  669. X            if (strncmp(cmd->Name, cmdbuf, cmdlen) == 0) {
  670. X                if (strcmp(cmd->Name, cmdbuf) == 0)
  671. X                    return (data_obj *) cmd;
  672. X                found += 1;
  673. X                which = cmd;
  674. X            }
  675. X            }
  676. X        if (found > 1)
  677. X            complain("[\"%s\" ambiguous]", cmdbuf);
  678. X        else if (found == 0)
  679. X            complain("[\"%s\" unknown]", cmdbuf);
  680. X        else
  681. X            return (data_obj *) which;
  682. X    } else {
  683. X        static char    *strings[(sizeof commands) / sizeof (commands[0])];
  684. X        static int    beenhere = NO;
  685. X        register int    com;
  686. X
  687. X        if (beenhere == NO) {
  688. X            register char    **strs = strings;
  689. X            register struct cmd    *c;
  690. X
  691. X            for (c = commands; c->Name != 0; c++)
  692. X                *strs++ = c->Name;
  693. X            *strs = 0;
  694. X            beenhere = YES;
  695. X        }
  696. X
  697. X        if ((com = complete(strings, prompt, CASEIND)) < 0)
  698. X            return 0;
  699. X        return (data_obj *) &commands[com];
  700. X    }
  701. X    /* NOTREACHED */
  702. X}
  703. X#endif
  704. END_OF_FILE
  705. if test 18218 -ne `wc -c <'./funcdefs.c'`; then
  706.     echo shar: \"'./funcdefs.c'\" unpacked with wrong size!
  707. fi
  708. # end of './funcdefs.c'
  709. fi
  710. if test -f './proc.c' -a "${1}" != "-c" ; then 
  711.   echo shar: Will not clobber existing file \"'./proc.c'\"
  712. else
  713. echo shar: Extracting \"'./proc.c'\" \(18101 characters\)
  714. sed "s/^X//" >'./proc.c' <<'END_OF_FILE'
  715. X/***************************************************************************
  716. X * This program is Copyright (C) 1986, 1987, 1988 by Jonathan Payne.  JOVE *
  717. X * is provided to you without charge, and with no warranty.  You may give  *
  718. X * away copies of JOVE, including sources, provided that this notice is    *
  719. X * included in all the files.                                              *
  720. X ***************************************************************************/
  721. X
  722. X#include "jove.h"
  723. X#include "io.h"
  724. X#include "termcap.h"
  725. X
  726. X#include <signal.h>
  727. X#include <varargs.h>
  728. X
  729. X#ifdef MSDOS
  730. X#include <io.h>
  731. X#include <process.h>
  732. X#endif
  733. X
  734. X
  735. X#ifdef    LINT_ARGS
  736. private void
  737. X    DoShell(char *, char *),
  738. X    com_finish(int, char *),
  739. X    toerror(int, int),
  740. X    closepipe(void);
  741. X    
  742. private int
  743. X    okay_error(void),
  744. X    openforpipe(void),
  745. X    reopenforpipe(void);
  746. X
  747. private struct error
  748. X    * AddError(struct error *, Line *, Buffer *, Line *, int);
  749. X#else
  750. private void
  751. X    DoShell(),
  752. X    com_finish(),
  753. X    toerror(),
  754. X    closepipe();
  755. X
  756. private int
  757. X    openforpipe(),
  758. X    okay_error(),
  759. X    reopenforpipe();
  760. X
  761. private struct error
  762. X    * AddError();
  763. X#endif
  764. X
  765. X
  766. X/* This disgusting RE search string parses output from the GREP
  767. X   family, from the pdp11 compiler, pcc, and lint.  Jay (HACK)
  768. X   Fenlasen changed this to work for the lint errors. */
  769. char    ErrFmtStr[256] = "^\\{\",\\}\\([^:\"( \t]*\\)\\{\"\\, line ,:,(\\} *\\([0-9][0-9]*\\)[:)]\
  770. X\\|::  *\\([^(]*\\)(\\([0-9]*\\))$\
  771. X\\|( \\([^(]*\\)(\\([0-9]*\\)) ),";
  772. X
  773. struct error {
  774. X    Buffer        *er_buf;    /* Buffer error is in */
  775. X    Line        *er_mess,    /* Actual error message */
  776. X            *er_text;    /* Actual error */
  777. X    int        er_char;    /* char pos of error */
  778. X    struct error    *er_prev,    /* List of errors */
  779. X            *er_next;
  780. X};
  781. X
  782. struct error    *cur_error = 0,
  783. X        *errorlist = 0;
  784. Buffer        *perr_buf = 0;    /* Buffer with error messages */
  785. X
  786. int    WtOnMk = 1;        /* Write the modified files when we make */
  787. X
  788. X/* Add an error to the end of the list of errors.  This is used for
  789. X   parse-{C,LINT}-errors and for the spell-buffer command */
  790. X
  791. private struct error *
  792. AddError(laste, errline, buf, line, charpos)
  793. struct error    *laste;
  794. Line    *errline,
  795. X    *line;
  796. Buffer    *buf;
  797. X{
  798. X    struct error    *new = (struct error *) emalloc(sizeof *new);
  799. X
  800. X    new->er_prev = laste;
  801. X    if (laste)
  802. X        laste->er_next = new;
  803. X    else {
  804. X        if (errorlist)        /* Free up old errors */
  805. X            ErrFree();
  806. X        cur_error = errorlist = new;
  807. X    }
  808. X    laste = new;
  809. X    new->er_next = 0;
  810. X    new->er_buf = buf;
  811. X    new->er_text = line;
  812. X    new->er_char = charpos;
  813. X    new->er_mess = errline;
  814. X
  815. X    return new;
  816. X}
  817. X
  818. X/* Parse errors of the form specified in ErrFmtStr in the current
  819. X   buffer.  Do a show error of the first error.  This is neat because this
  820. X   will work for any kind of output that prints a file name and a line
  821. X   number on the same line. */
  822. X
  823. void
  824. ErrParse()
  825. X{
  826. X    Bufpos    *bp;
  827. X    char    fname[FILESIZE],
  828. X        lineno[10],
  829. X        REbuf[256],
  830. X        *REalts[10];
  831. X    int    lnum,
  832. X        last_lnum = -1;
  833. X    struct error    *ep = 0;
  834. X    Buffer    *buf,
  835. X        *lastb = 0;
  836. X    Line    *err_line;    
  837. X
  838. X    ErrFree();        /* This is important! */
  839. X    ToFirst();
  840. X    perr_buf = curbuf;
  841. X    REcompile(ErrFmtStr, 1, REbuf, REalts);
  842. X    /* Find a line with a number on it. */
  843. X    while (bp = docompiled(FORWARD, REbuf, REalts)) {
  844. X        SetDot(bp);
  845. X        putmatch(1, fname, sizeof fname);
  846. X        putmatch(2, lineno, sizeof lineno);
  847. X        buf = do_find((Window *) 0, fname, 1);
  848. X        if (buf != lastb) {
  849. X            lastb = buf;
  850. X            last_lnum = -1;        /* signals new file */
  851. X            err_line = buf->b_first;
  852. X        }
  853. X        (void) chr_to_int(lineno, 10, NO, &lnum);
  854. X        if (lnum == last_lnum)    /* one error per line is nicer */
  855. X            continue;
  856. X        if (last_lnum == -1)
  857. X            last_lnum = 1;    /* that's where we really are */
  858. X        err_line = next_line(err_line, lnum - last_lnum);
  859. X        ep = AddError(ep, curline, buf, err_line, 0);
  860. X        last_lnum = lnum;
  861. X    }
  862. X    if (cur_error != 0)
  863. X        ShowErr();
  864. X}
  865. X
  866. X/* Free up all the errors */
  867. X
  868. void
  869. ErrFree()
  870. X{
  871. X    register struct error    *ep;
  872. X
  873. X    for (ep = errorlist; ep != 0; ep = ep->er_next)
  874. X        free((char *) ep);
  875. X    errorlist = cur_error = 0;
  876. X}
  877. X
  878. X/* Internal next error sets cur_error to the next error, taking the
  879. X   argument count, supplied by the user, into consideration. */
  880. X
  881. private char    errbounds[] = "You're at the %s error.",
  882. X        noerrs[] = "No errors!";
  883. X
  884. private void
  885. toerror(forward, num)
  886. X{
  887. X    register struct error    *e = cur_error;
  888. X
  889. X    if (e == 0)
  890. X        complain(noerrs);
  891. X    if ((forward && (e->er_next == 0)) ||
  892. X        (!forward && (e->er_prev == 0)))
  893. X        complain(errbounds, forward ? "last" : "first");
  894. X
  895. X    while (--num >= 0) {
  896. X        if ((e = forward ? e->er_next : e->er_prev) == 0)
  897. X            break;
  898. X        cur_error = e;
  899. X    }
  900. X}
  901. X
  902. void
  903. NextError()
  904. X{
  905. X    ToError(1);
  906. X}
  907. X
  908. void
  909. PrevError()
  910. X{
  911. X    ToError(0);
  912. X}
  913. X
  914. private int
  915. okay_error()
  916. X{
  917. X    return ((inlist(perr_buf->b_first, cur_error->er_mess)) &&
  918. X        (inlist(cur_error->er_buf->b_first, cur_error->er_text)));
  919. X}
  920. X
  921. X/* Go the the next error, if there is one.  Put the error buffer in
  922. X   one window and the buffer with the error in another window.
  923. X   It checks to make sure that the error actually exists. */
  924. X
  925. void
  926. ToError(forward)
  927. X{
  928. X    do {
  929. X        toerror(forward, arg_value());
  930. X    } while (!okay_error());
  931. X    ShowErr();
  932. X}
  933. X
  934. int    EWSize = 20;    /* percentage of screen the error window
  935. X               should be */
  936. X
  937. void
  938. set_wsize(wsize)
  939. int    wsize;
  940. X{
  941. X    wsize = (LI * wsize) / 100;
  942. X    if (wsize >= 1 && !one_windp())
  943. X        WindSize(curwind, wsize - (curwind->w_height - 1));
  944. X}
  945. X
  946. X/* Show the current error, i.e. put the line containing the error message
  947. X   in one window, and the buffer containing the actual error in another
  948. X   window. */
  949. X
  950. void
  951. ShowErr()
  952. X{
  953. X    Window    *err_wind,
  954. X        *buf_wind;
  955. X
  956. X    if (cur_error == 0)
  957. X        complain(noerrs);
  958. X    if (!okay_error()) {
  959. X        rbell();
  960. X        return;
  961. X    }
  962. X    err_wind = windbp(perr_buf);
  963. X    buf_wind = windbp(cur_error->er_buf);
  964. X
  965. X    if (err_wind && !buf_wind) {
  966. X        SetWind(err_wind);
  967. X        pop_wind(cur_error->er_buf->b_name, NO, -1);
  968. X        buf_wind = curwind;
  969. X    } else if (!err_wind && buf_wind) {
  970. X        SetWind(buf_wind);
  971. X        pop_wind(perr_buf->b_name, NO, -1);
  972. X        err_wind = curwind;
  973. X    } else if (!err_wind && !buf_wind) {
  974. X        pop_wind(perr_buf->b_name, NO, -1);
  975. X        err_wind = curwind;
  976. X        pop_wind(cur_error->er_buf->b_name, NO, -1);
  977. X        buf_wind = curwind;
  978. X    }
  979. X
  980. X    /* Put the current error message at the top of its Window */
  981. X    SetWind(err_wind);
  982. X    SetLine(cur_error->er_mess);
  983. X    SetTop(curwind, (curwind->w_line = cur_error->er_mess));
  984. X    set_wsize(EWSize);
  985. X
  986. X    /* now go to the the line with the error in the other window */
  987. X    SetWind(buf_wind);
  988. X    DotTo(cur_error->er_text, cur_error->er_char);
  989. X}
  990. X
  991. char    ShcomBuf[128] = {0};
  992. X
  993. X/* Make a buffer name given the command `command', i.e. "fgrep -n foo *.c"
  994. X   will return the buffer name "fgrep".  */
  995. X
  996. char *
  997. MakeName(command)
  998. char    *command;
  999. X{
  1000. X    static char    bufname[50];
  1001. X    register char    *cp = bufname,
  1002. X            c;
  1003. X
  1004. X    while ((c = *command++) && (c == ' ' || c == '\t'))
  1005. X        ;
  1006. X    do
  1007. X        *cp++ = c;
  1008. X    while ((c = *command++) && (c != ' ' && c != '\t'));
  1009. X    *cp = 0;
  1010. X    strcpy(bufname, basename(bufname));
  1011. X
  1012. X    return bufname;
  1013. X}
  1014. X
  1015. X/* Run make, first writing all the modified buffers (if the WtOnMk flag is
  1016. X   non-zero), parse the errors, and go the first error. */
  1017. X
  1018. char    make_cmd[128] = "make";
  1019. X
  1020. void
  1021. MakeErrors()
  1022. X{
  1023. X    Window    *old = curwind;
  1024. X    int    status,
  1025. X        compilation;
  1026. X    
  1027. X    if (WtOnMk)
  1028. X        put_bufs(0);
  1029. X    /* When we're not doing make or cc (i.e., the last command
  1030. X       was probably a grep or something) and the user just types
  1031. X       C-X C-E, he probably (possibly, hopefully, usually (in my
  1032. X       case)) doesn't want to do the grep again but rather wants
  1033. X       to do a make again; so we ring the bell and insert the
  1034. X       default command and let the person decide. */
  1035. X
  1036. X    compilation = (sindex("make", make_cmd) || sindex("cc", make_cmd));
  1037. X    if (is_an_arg() || !compilation) {
  1038. X        if (!compilation) {
  1039. X            rbell();
  1040. X            Inputp = make_cmd;    /* insert the default for the user */
  1041. X        }
  1042. X        null_ncpy(make_cmd, ask(make_cmd, "Compilation command: "),
  1043. X                sizeof (make_cmd) - 1);
  1044. X    }
  1045. X    status = UnixToBuf(MakeName(make_cmd), YES, EWSize, YES, Shell, ShFlags, make_cmd, (char *) 0);
  1046. X    com_finish(status, make_cmd);
  1047. X
  1048. X    ErrParse();
  1049. X
  1050. X    if (!cur_error)
  1051. X        SetWind(old);
  1052. X}
  1053. X
  1054. X#ifdef SPELL
  1055. X
  1056. void
  1057. SpelBuffer()
  1058. X{
  1059. X    char    *Spell = "Spell",
  1060. X        com[100];
  1061. X    Window    *savewp = curwind;
  1062. X
  1063. X    put_bufs(0);
  1064. X    sprintf(com, "spell %s", curbuf->b_fname);
  1065. X    (void) UnixToBuf(Spell, YES, EWSize, YES, Shell, ShFlags, com, (char *) 0);
  1066. X    message("[Delete the irrelevant words and then type C-X C-C]");
  1067. X    ToFirst();
  1068. X    Recur();
  1069. X    SetWind(savewp);
  1070. X    SpelParse(Spell);
  1071. X}
  1072. X
  1073. void
  1074. SpelWords()
  1075. X{
  1076. X    char    *buftospel;
  1077. X    Buffer    *wordsb = curbuf;
  1078. X
  1079. X    if ((buftospel = ask_buf((Buffer *) 0)) == 0)
  1080. X        return;
  1081. X    SetBuf(do_select(curwind, buftospel));
  1082. X    SpelParse(wordsb->b_name);
  1083. X}
  1084. X
  1085. void
  1086. SpelParse(bname)
  1087. char    *bname;
  1088. X{
  1089. X    Buffer    *buftospel,
  1090. X        *wordsb;
  1091. X    char    wordspel[100];
  1092. X    Bufpos    *bp;
  1093. X    struct error    *ep = 0;
  1094. X
  1095. X    ErrFree();        /* This is important! */
  1096. X
  1097. X    buftospel = curbuf;
  1098. X    wordsb = buf_exists(bname);
  1099. X    perr_buf = wordsb;    /* This is important (buffer containing
  1100. X                   error messages) */
  1101. X    SetBuf(wordsb);
  1102. X    ToFirst();
  1103. X    f_mess("Finding misspelled words ... ");
  1104. X    while (!lastp(curline)) {
  1105. X        sprintf(wordspel, "\\<%s\\>", linebuf);
  1106. X        SetBuf(buftospel);
  1107. X        ToFirst();
  1108. X        while (bp = dosearch(wordspel, 1, 1)) {
  1109. X            SetDot(bp);
  1110. X            ep = AddError(ep, wordsb->b_dot, buftospel,
  1111. X                      curline, curchar);
  1112. X        }
  1113. X        SetBuf(wordsb);
  1114. X        line_move(FORWARD, 1, NO);
  1115. X    }
  1116. X    add_mess("Done.");
  1117. X    SetBuf(buftospel);
  1118. X    ShowErr();
  1119. X}
  1120. X
  1121. X#endif /* SPELL */
  1122. X
  1123. void
  1124. ShToBuf()
  1125. X{
  1126. X    char    bufname[128],
  1127. X        cmd[128];
  1128. X
  1129. X    strcpy(bufname, ask((char *) 0, "Buffer: "));
  1130. X    strcpy(cmd, ask(ShcomBuf, "Command: "));
  1131. X    DoShell(bufname, cmd);
  1132. X}
  1133. X
  1134. void
  1135. ShellCom()
  1136. X{
  1137. X    null_ncpy(ShcomBuf, ask(ShcomBuf, ProcFmt), (sizeof ShcomBuf) - 1);
  1138. X    DoShell(MakeName(ShcomBuf), ShcomBuf);
  1139. X}
  1140. X
  1141. ShNoBuf()
  1142. X{
  1143. X    int    status;
  1144. X
  1145. X    null_ncpy(ShcomBuf, ask(ShcomBuf, ProcFmt), (sizeof ShcomBuf) - 1);
  1146. X    status = UnixToBuf((char *) 0, NO, 0, NO, Shell, ShFlags, ShcomBuf, (char *) 0);
  1147. X    com_finish(status, ShcomBuf);
  1148. X}
  1149. X
  1150. Shtypeout()
  1151. X{
  1152. X    int    status;
  1153. X
  1154. X    null_ncpy(ShcomBuf, ask(ShcomBuf, ProcFmt), (sizeof ShcomBuf) - 1);
  1155. X    status = UnixToBuf((char *) 0, YES, 0, NO, Shell, ShFlags, ShcomBuf, (char *) 0);
  1156. X    if (status == 0)
  1157. X        Typeout("[%s: completed successfully]", ShcomBuf);
  1158. X    else
  1159. X        Typeout("[%s: exited (%d)]", ShcomBuf, status);
  1160. X    TOstop();
  1161. X}
  1162. X
  1163. X/* Run the shell command into `bufname'.  Empty the buffer except when we
  1164. X   give a numeric argument, in which case it inserts the output at the
  1165. X   current position in the buffer.  */
  1166. X
  1167. private void
  1168. DoShell(bufname, command)
  1169. char    *bufname,
  1170. X    *command;
  1171. X{
  1172. X    Window    *savewp = curwind;
  1173. X    int    status;
  1174. X
  1175. X    status = UnixToBuf(bufname, YES, 0, !is_an_arg(), Shell,
  1176. X               ShFlags, command, (char *) 0);
  1177. X    com_finish(status, command);
  1178. X    SetWind(savewp);
  1179. X}
  1180. X
  1181. private void
  1182. com_finish(status, cmd)
  1183. int    status;
  1184. char    *cmd;
  1185. X{
  1186. X    s_mess("[%s: ", cmd);
  1187. X    if (status == 0)
  1188. X        add_mess("completed successfully");
  1189. X    else
  1190. X        add_mess("exited (%d)", status);
  1191. X    add_mess("]");
  1192. X}
  1193. X
  1194. X#ifndef MSDOS
  1195. void
  1196. dowait(pid, status)
  1197. int    pid,
  1198. X    *status;
  1199. X{
  1200. X#ifndef IPROCS
  1201. X
  1202. X    int    rpid;
  1203. X
  1204. X    while ((rpid = wait(status)) != pid)
  1205. X        ;
  1206. X#else
  1207. X
  1208. X#ifdef BSD4_2
  1209. X#   include <sys/wait.h>
  1210. X#else
  1211. X#   include <wait.h>
  1212. X#endif
  1213. X
  1214. X    union wait    w;
  1215. X    int    rpid;
  1216. X
  1217. X    for (;;) {
  1218. X#ifndef BSD4_2
  1219. X        rpid = wait2(&w.w_status, 0);
  1220. X#else
  1221. X        rpid = wait3(&w, 0, (struct rusage *) 0);
  1222. X#endif
  1223. X        if (rpid == pid) {
  1224. X            if (status)
  1225. X                *status = w.w_status;
  1226. X            break;
  1227. X        } else
  1228. X            kill_off(rpid, w);
  1229. X    }
  1230. X#endif /* IPROCS */
  1231. X}
  1232. X
  1233. X#endif /* MSDOS */
  1234. X/* Run the command to bufname, erase the buffer if clobber is non-zero,
  1235. X   and redisplay if disp is non-zero.  Leaves current buffer in `bufname'
  1236. X   and leaves any windows it creates lying around.  It's up to the caller
  1237. X   to fix everything up after we're done.  (Usually there's nothing to
  1238. X   fix up.) */
  1239. X
  1240. X/* VARARGS5 */
  1241. X
  1242. int
  1243. UnixToBuf(bufname, disp, wsize, clobber, va_alist)
  1244. char    *bufname;
  1245. va_dcl
  1246. X{
  1247. X#ifndef MSDOS
  1248. X    int    p[2],
  1249. X        pid,
  1250. X        status,
  1251. X#else /* MSDOS */
  1252. X    int    p0,
  1253. X        oldo,
  1254. X        olde,
  1255. X        retcode,
  1256. X#endif /* MSDOS */
  1257. X        eof;
  1258. X    va_list    ap;
  1259. X    char    *argv[32],
  1260. X        *mess;
  1261. X    File    *fp;
  1262. X    int    (*old_int)();
  1263. X
  1264. X    va_start(ap);
  1265. X    make_argv(argv, ap);
  1266. X    va_end(ap);
  1267. X    if (bufname != 0 && clobber == YES)
  1268. X        isprocbuf(bufname);
  1269. X    if (disp) {
  1270. X        if (bufname != 0)
  1271. X            message("Starting up...");
  1272. X        else {
  1273. X            TOstart(argv[0], TRUE);
  1274. X            Typeout("Starting up...");
  1275. X        }
  1276. X        if (bufname != 0) {
  1277. X            pop_wind(bufname, clobber, clobber ? B_PROCESS : B_FILE);
  1278. X            set_wsize(wsize);
  1279. X            redisplay();
  1280. X        }
  1281. X    }
  1282. X    /* Now I will attempt to describe how I deal with signals during
  1283. X       the execution of the shell command.  My desire was to be able
  1284. X       to interrupt the shell command AS SOON AS the window pops up.
  1285. X       So, if we have JOB_CONTROL (i.e., the new signal mechanism) I
  1286. X       hold SIGINT, meaning if we interrupt now, we will eventually
  1287. X       see the interrupt, but not before we are ready for it.  We
  1288. X       fork, the child releases the interrupt, it then sees the
  1289. X       interrupt, and so exits.  Meanwhile the parent ignores the
  1290. X       signal, so if there was a pending one, it's now lost.
  1291. X
  1292. X       With no JOB_CONTROL, the best behavior you can expect is, when
  1293. X       you type ^] too very quickly after the window pops up, it may
  1294. X       be ignored.  The behavior BEFORE was that it would interrupt
  1295. X       JOVE and then you would have to continue JOVE and wait a
  1296. X       little while longer before trying again.  Now that is fixed,
  1297. X       in that you just have to type it twice. */
  1298. X
  1299. X#ifndef MSDOS
  1300. X#ifdef IPROCS
  1301. X    sighold(SIGCHLD);
  1302. X#endif
  1303. X#ifdef JOB_CONTROL
  1304. X    sighold(SIGINT);
  1305. X#else
  1306. X    old_int = signal(SIGINT, SIG_IGN),
  1307. X#endif
  1308. X    dopipe(p);
  1309. X    pid = fork();
  1310. X    if (pid == -1) {
  1311. X        pclose(p);
  1312. X        complain("[Fork failed]");
  1313. X    }
  1314. X    if (pid == 0) {
  1315. X#ifdef IPROCS
  1316. X        sigrelse(SIGCHLD);   /* don't know if this matters */
  1317. X#endif /* IPROCS */
  1318. X        (void) signal(SIGINT, SIG_DFL);
  1319. X#ifdef JOB_CONTROL
  1320. X        sigrelse(SIGINT);
  1321. X#endif
  1322. X        (void) close(0);
  1323. X        (void) open("/dev/null", 0);
  1324. X        (void) close(1);
  1325. X        (void) close(2);
  1326. X        (void) dup(p[1]);
  1327. X        (void) dup(p[1]);
  1328. X        pclose(p);
  1329. X        execv(argv[0], &argv[1]);
  1330. X        (void) write(1, "Execl failed.\n", 14);
  1331. X        _exit(1);
  1332. X    }
  1333. X#ifdef JOB_CONTROL
  1334. X    old_int = signal(SIGINT, SIG_IGN);
  1335. X#endif    
  1336. X    (void) close(p[1]);
  1337. X    fp = fd_open(argv[1], F_READ, p[0], iobuff, LBSIZE);
  1338. X#else /* MSDOS */
  1339. X    if ((p0 = openforpipe()) < 0)
  1340. X       complain("cannot make pipe for filter");
  1341. X
  1342. X    oldo = dup(1);
  1343. X    olde = dup(2);
  1344. X    close(1);
  1345. X    close(2);
  1346. X    dup(p0);
  1347. X    dup(1);
  1348. X    close(p0);
  1349. X    retcode = spawnv(0, argv[0], &argv[1]);
  1350. X    p0 = reopenforpipe();
  1351. X    close(1);
  1352. X    close(2);
  1353. X    dup(oldo);
  1354. X    dup(olde);
  1355. X    close(oldo);
  1356. X    close(olde);
  1357. X
  1358. X    if (retcode < 0)
  1359. X        complain("[Spawn failed]");
  1360. X
  1361. X    fp = fd_open(argv[1], F_READ, p0, iobuff, LBSIZE);
  1362. X#endif /* MSDOS */
  1363. X    do {
  1364. X#ifndef MSDOS
  1365. X        inIOread = 1;
  1366. X#endif
  1367. X         eof = f_gets(fp, genbuf, LBSIZE);
  1368. X#ifndef MSDOS
  1369. X        inIOread = 0;
  1370. X#endif
  1371. X        if (bufname != 0) {
  1372. X            ins_str(genbuf, YES);
  1373. X            if (!eof)
  1374. X                LineInsert(1);
  1375. X        } else if (disp == YES)
  1376. X            Typeout("%s", genbuf);
  1377. X        if (bufname != 0 && disp != 0 && fp->f_cnt <= 0) {
  1378. X#ifdef LOAD_AV
  1379. X            {
  1380. X                double    theavg;
  1381. X
  1382. X            get_la(&theavg);
  1383. X            if (theavg < 2.0)
  1384. X                mess = "Screaming along...";
  1385. X            else if (theavg < 5.0)
  1386. X                mess = "Chugging along...";
  1387. X            else
  1388. X                mess = "Crawling along...";
  1389. X            }
  1390. X#else
  1391. X            mess = "Chugging along...";
  1392. X#endif /* LOAD_AV */
  1393. X            if (bufname != 0) {
  1394. X                message(mess);
  1395. X                redisplay();
  1396. X            }
  1397. X        }
  1398. X    } while (!eof);
  1399. X    if (disp)
  1400. X        DrawMesg(NO);
  1401. X    close_file(fp);
  1402. X#ifndef MSDOS
  1403. X    dowait(pid, &status);
  1404. X#ifdef JOB_CONTROL
  1405. X    (void) sigrelse(SIGINT);
  1406. X#endif
  1407. X#else /* MSDOS */
  1408. X    closepipe();
  1409. X#endif /* MSDOS */
  1410. X    (void) signal(SIGINT, old_int);
  1411. X#ifndef MSDOS
  1412. X#ifdef IPROCS
  1413. X    sigrelse(SIGCHLD);
  1414. X#endif
  1415. X    return status;
  1416. X#else /* MSDOS */
  1417. X#ifdef CHDIR
  1418. X    getCWD();
  1419. X#endif    
  1420. X    return retcode;
  1421. X#endif /* MSDOS */
  1422. X}
  1423. X
  1424. X#ifndef MSDOS
  1425. X#ifdef BSD4_2
  1426. X
  1427. private long    SigMask = 0;
  1428. X
  1429. X#ifndef sigmask
  1430. X#    define    sigmask(s)    (1L << ((s)-1))
  1431. X#endif
  1432. X
  1433. sighold(sig)
  1434. X{
  1435. X    (void) sigblock(SigMask |= sigmask(sig));
  1436. X}
  1437. X
  1438. sigrelse(sig)
  1439. X{
  1440. X    (void) sigsetmask(SigMask &= ~sigmask(sig));
  1441. X}
  1442. X
  1443. X#endif
  1444. X
  1445. X#endif /* MSDOS */
  1446. X
  1447. void
  1448. FilterRegion()
  1449. X{
  1450. X    char    *cmd = ask((char *) 0, ": %f (through command) ", ProcFmt);
  1451. X
  1452. X    RegToUnix(curbuf, cmd);
  1453. X}
  1454. X
  1455. X/* Send the current region to CMD and insert the output from the
  1456. X   command into OUT_BUF. */
  1457. X
  1458. void
  1459. RegToUnix(outbuf, cmd)
  1460. Buffer    *outbuf;
  1461. char    *cmd;
  1462. X{
  1463. X    Mark    *m = CurMark();
  1464. X#ifndef MSDOS
  1465. X    char    *tname = mktemp("/tmp/jfilterXXXXXX"),
  1466. X        combuf[128];
  1467. X#endif /* MSDOS */
  1468. X    Window    *save_wind = curwind;
  1469. X    int    status,
  1470. X        error = NO;
  1471. X#ifdef MSDOS
  1472. X    int p0, oldi;
  1473. X#endif /* MSDOS */
  1474. X    File    *fp;
  1475. X
  1476. X#ifndef MSDOS
  1477. X    fp = open_file(tname, iobuff, F_WRITE, COMPLAIN, QUIET);
  1478. X#else /* MSDOS */
  1479. X    p0 = openforpipe();
  1480. X#endif /* MSDOS */
  1481. X    CATCH
  1482. X#ifdef MSDOS
  1483. X    fp = fd_open(cmd, F_WRITE, p0, iobuff, LBSIZE);
  1484. X#endif /* MSDOS */
  1485. X    putreg(fp, m->m_line, m->m_char, curline, curchar, YES);
  1486. X    DelReg();
  1487. X#ifndef MSDOS
  1488. X    sprintf(combuf, "%s < %s", cmd, tname);
  1489. X#else /* MSDOS */
  1490. X    f_close(fp);
  1491. X    p0 = reopenforpipe();
  1492. X    oldi = dup(0);
  1493. X    close(0);
  1494. X    dup(p0);
  1495. X    close(p0);
  1496. X#endif /* MSDOS */
  1497. X    status = UnixToBuf(outbuf->b_name, NO, 0, outbuf->b_type == B_SCRATCH,
  1498. X#ifndef MSDOS
  1499. X               Shell, ShFlags, combuf, (char *) 0);
  1500. X#else /* MSDOS */
  1501. X               Shell, ShFlags, cmd, (char *) 0);
  1502. X#endif /* MSDOS */
  1503. X    ONERROR
  1504. X    error = YES;
  1505. X    ENDCATCH
  1506. X#ifndef MSDOS
  1507. X    f_close(fp);
  1508. X    (void) unlink(tname);
  1509. X#else /* MSDOS */
  1510. X    close(0);
  1511. X    open("con", 0);    /* dup(oldi);    */
  1512. X    close(oldi);
  1513. X    closepipe();
  1514. X#endif /* MSDOS */
  1515. X    SetWind(save_wind);
  1516. X    if (error == NO)
  1517. X#ifndef MSDOS
  1518. X        com_finish(status, combuf);
  1519. X#else
  1520. X        com_finish(status, cmd);
  1521. X#endif
  1522. X}
  1523. X
  1524. void
  1525. isprocbuf(bufname)
  1526. char    *bufname;
  1527. X{
  1528. X    Buffer    *bp;
  1529. X
  1530. X    if ((bp = buf_exists(bufname)) != 0 && bp->b_type != B_PROCESS)
  1531. X        confirm("Over-write buffer %s?", bufname);
  1532. X}
  1533. X
  1534. X#ifdef MSDOS
  1535. X/*    msdos specific hacks to allow for pipes */
  1536. X
  1537. X#include <dos.h>
  1538. X#include <fcntl.h>
  1539. X#include <sys/types.h>
  1540. X#include <sys/stat.h>
  1541. X
  1542. static char pipeiname[64];
  1543. static char pipeoname[64];
  1544. static int  pipehandle;
  1545. X
  1546. extern char TmpFilePath[];
  1547. X
  1548. private int
  1549. openforpipe()
  1550. X{
  1551. X   sprintf(pipeiname, "%s/%s", TmpFilePath, "Jove-I");
  1552. X   sprintf(pipeoname, "%s/%s", TmpFilePath, "Jove-O");
  1553. X
  1554. X   return(pipehandle = creat(pipeoname, S_IWRITE|S_IREAD));
  1555. X}
  1556. X
  1557. private int
  1558. reopenforpipe()
  1559. X{               
  1560. X   close(pipehandle);
  1561. X   unlink(pipeiname);
  1562. X   rename(pipeoname, pipeiname);
  1563. X   if ((pipehandle = open(pipeiname, 0)) >= 0)
  1564. X      return(pipehandle);
  1565. X   closepipe();
  1566. X   return(-1);
  1567. X}
  1568. X
  1569. private void
  1570. closepipe()
  1571. X{     
  1572. X   unlink(pipeoname);
  1573. X   unlink(pipeiname);
  1574. X}
  1575. X         
  1576. char 
  1577. switchar()
  1578. X{
  1579. X  union REGS regs;
  1580. X  
  1581. X  regs.h.ah = 0x37;
  1582. X  regs.h.al = 0;   
  1583. X  intdos(®s, ®s);
  1584. X  return(regs.h.dl);
  1585. X}
  1586. X#endif /* MSDOS */
  1587. END_OF_FILE
  1588. if test 18101 -ne `wc -c <'./proc.c'`; then
  1589.     echo shar: \"'./proc.c'\" unpacked with wrong size!
  1590. fi
  1591. # end of './proc.c'
  1592. fi
  1593. echo shar: End of archive 9 \(of 21\).
  1594. cp /dev/null ark9isdone
  1595. MISSING=""
  1596. for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ; do
  1597.     if test ! -f ark${I}isdone ; then
  1598.     MISSING="${MISSING} ${I}"
  1599.     fi
  1600. done
  1601. if test "${MISSING}" = "" ; then
  1602.     echo You have unpacked all 21 archives.
  1603.     rm -f ark[1-9]isdone ark[1-9][0-9]isdone
  1604. else
  1605.     echo You still need to unpack the following archives:
  1606.     echo "        " ${MISSING}
  1607. fi
  1608. ##  End of shell archive.
  1609. exit 0
  1610.